Repository navigation
device: fit a Qwen4 pack by the bytes it holds in GPU memory - #6477
Merged
Merged
Conversation
Owner
Author
|
READY to land on this head. Device report only (CLI fit check); no served path, kernels or tokens touched. test-device, test-cli, check-native-cuda-host, test-cli-host, test-gradient-serving, test-qwen4-host, test-qwen4-ple-host, fmt/AST and pr_check pass; each new test fails without its change.
|
Owner
Author
|
READY to land on this head. Device report and tensorfold info only; no served path, kernels or tokens touched. test-device, test-cli, check-native-cuda-host, test-cli-host, test-gradient-serving, test-qwen4-host, test-qwen4-ple-host, fmt/AST and pr_check pass; each new test fails without its change.
|
This was referenced Dec 5, 2026
The Qwen4 engine never uploads its PLE n-gram tables: device_weights `take` skips every table role and `lookup` reads the needed rows from the read-only mapping each step. `tensorfold device` still compared the whole snapshot with the weight budget, so a 64 GB Mac read the Qwen4-35B-A3B TFQ packs (53 to 63 GiB on disk, 17.5 to 26.9 GiB resident) as too large. models.onDisk now also returns the resident bytes: the snapshot's size less the `.ple.ple_embedding.ngram_embedding.` tensors in its safetensors headers, for qwen4 and qwen4_text only. The device verdict uses that, and the report line names both sizes when they differ. Load, kernels and output tokens are unchanged; other families keep their whole size.
`tensorfold info` still printed a Qwen4 checkpoint's whole snapshot as its weights and priced the memory floor on it, while `tensorfold device` now uses the resident bytes. For qwen4 and qwen4_text, info now takes the same resident.residentBytes: the weights line names the bytes held in GPU memory, a new "on disk:" line names the snapshot's size and the PLE lookup tables left on disk, and the floor adds the margin to the resident bytes. Every other family prints byte for byte as before. Load, kernels and output tokens are unchanged.
ashhart
force-pushed
the
lead/qwen4-device-fit
branch
from
December 5, 2026 12:37
ef5b8ca to
7d2417b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tensorfold devicecompared a Qwen4 checkpoint's whole snapshot with the machine's weight budget. The Qwen4 engine never uploads its PLE n-gram tables: it reads the rows each step needs from the read-only file mapping. So a 64 GB Mac reported the Qwen4-35B-A3B TFQ packs (53 to 63 GiB on disk, 17.5 to 26.9 GiB held in GPU memory) as too large, although they load.What changes:
cli/resident.zig: sums the.ple.ple_embedding.ngram_embedding.tensors from each safetensors header (no tensor bytes read), forqwen4andqwen4_textonly. Every other family keeps its whole size.models.onDiskreturns the resident bytes;tensorfold devicefits by them and the report line names both sizes when they differ, e.g.60.8 GiB (25.0 GiB in GPU memory; its lookup tables stay on disk): fits.--jsongains aresidentfield.too_largeby size on disk andfitsby resident bytes.Load path, kernels and output tokens are unchanged; no new refusal.
Checks:
test-device(2 new tests),test-cli(same results as main plus the new test),check-native-cuda-host,test-cli-host,test-gradient-serving,test-qwen4-host,test-qwen4-ple-host,zig fmt --check --ast-check,pr_check.py --base main(lean, cycle and cross-family counts unchanged). Each new test fails when its change is removed.